var url = tinyMCE.getParam("flash_external_list_url");
if (url != null) {
	// Fix relative
	if (url.charAt(0) != '/' && url.indexOf('://') == -1)
		url = tinyMCE.documentBasePath + "/" + url;

	document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></sc'+'ript>');
}

function insertFlash(nID,nW,nH,sAlign) {
	var html      = '';
	var file      = tinyMCE.documentBasePath+'/get.php?s.'+nID;
	var width     = nW;
	var height    = nH;
	var align     = sAlign;
	if (width == "") width = 100;
	if (height == "") height = 100;
	if (align == "") align = '';

	html += ''
		+ '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" mce_src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
		+ 'width="' + width + '" height="' + height + '" '
		+ 'border="0" alt="' + file + '" title="' + file + '" class="mceItemFlash" align="'+align+'"/>';

	tinyMCEPopup.execCommand("mceInsertContent", true, html);
	tinyMCE.selectedInstance.repaint();

	tinyMCEPopup.close();
}

function insertPopAction(nID,nW,nH,sName) {

	var anySelection = false;
	var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
	var focusElm = inst.getFocusElement();
	var selectedText = inst.selection.getSelectedText();

	tinyMCEPopup.execCommand("mceBeginUndoLevel");

	var html = '<a href="javascript:void(0);" onclick="return openFlashPopupID('+nID+', '+nW+', '+nH+', \''+sName+'\')" title="'+sName+'">';
	
	if (tinyMCE.selectedElement)
		anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);

	if (anySelection || (focusElm != null && focusElm.nodeName == "A")) {
		tinyMCEPopup.execCommand("mceInsertContent", false, html + inst.selection.getSelectedHTML() + '</a>');
	} else {
		//alert('Nera');
	}
				
	tinyMCE._setEventsEnabled(inst.getBody(), false);
	tinyMCEPopup.execCommand("mceEndUndoLevel");
}
